import request from '@/utils/request'

// 获取导航栏目录数据
export function getNavTitleList() {
    return request({
        url: '/category/titleCategoryList',
        method: 'GET'
    })
}

// 更新导航栏目录数据
export function updateNavTitleList(data) {
    return request({
        url: '/category/titleCategoryList',
        method: 'PUT',
        data
    })
}

// 获取大类树
export function getCategoryTree(params) {
    return request({
        url: '/category/tree',
        method: 'GET',
        params
    })
}

// 获取大类详情
export function getCategoryDetail(id) {
    return request({
        url: '/category/' + id,
        method: 'GET'
    }).then(data => data.category)
}

// 更新大类详情
export function updateCategory(id, data) {
    return request({
        url: '/category/' + id,
        method: 'PUT',
        data
    })
}

// 新建大类
export function createCategory(data) {
    return request({
        url: '/category',
        method: 'POST',
        data
    }).then(data => data.category)
}

// 删除大类
export function deleteCategory(id) {
    return request({
        url: '/category/' + id,
        method: 'DELETE'
    })
}

// 修改大类顺序
export function changeCategoryOrder(data) {
    return request({
        url: '/category/order',
        method: 'PATCH',
        data
    })
}

// 批量处理, 均传id数组
// 批量设置可见
export function batchCategoryVisible(data) {
    return request({
        url: '/category/setVisible',
        method: 'PATCH',
        data
    })
}

// 批量设置不可见
export function batchCategoryInvisible(data) {
    return request({
        url: '/category/setInvisible',
        method: 'PATCH',
        data
    })
}

// 批量删除
export function batchCategoryDelete(data) {
    return request({
        url: '/category/deleteSome',
        method: 'DELETE',
        data
    })
}
